(function() {
  var __hasProp = {}.hasOwnProperty,
    __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

  this.BooksView = (function(_super) {

    __extends(BooksView, _super);

    function BooksView() {
      return BooksView.__super__.constructor.apply(this, arguments);
    }

    BooksView.prototype.initialize = function() {
      BooksView.__super__.initialize.apply(this, arguments);
      this.setElement("#main");
      this.model.bind("change", this.render);
      return this.model.fetch();
    };

    BooksView.prototype.events = {
      "click ul.star-rating li a": "rate"
    };

    BooksView.prototype.rate = function(e) {
      var rating, ratingModel, ratingView, ul;
      e.preventDefault();
      rating = $(e.currentTarget);
      ul = rating.closest("ul.star-rating:not(.disabled)");
      if (ul.length > 0) {
        ratingModel = new RatingModel();
        ratingModel.set({
          "BookId": ul.data("val-bookid"),
          "RatingValue": rating.data("rate-value")
        });
        return ratingView = new RatingView({
          model: ratingModel,
          el: $(ul)
        });
      }
    };

    BooksView.prototype.render = function() {
      var _this = this;
      return $.get(SiteMap.Books.IndexTemplate, function(template) {
        var complitedTemplate, responseModel, responseView;
        complitedTemplate = _.template(template);
        $(_this.el).html(complitedTemplate(_this.model.toJSON()));
        responseModel = new ResponsesModel();
        responseModel.set("BookId", _this.model.get("BookId"));
        return responseView = new ResponsesView({
          el: $("#responses"),
          model: responseModel
        });
      });
    };

    return BooksView;

  })(CustomView);

}).call(this);
